<?php namespace App\Http\Controllers\user\information;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use Input;
use App\Models\News;
use App;

use Illuminate\Pagination\LengthAwarePaginator;
use Landish\Pagination\Pagination as BootstrapPresenter;

class NewsController extends Controller {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$numPerPage = 20;
		$type = Input::get("type");
		$model = News::where("type", $type)->paginate($numPerPage);
		$count = $model->count();

		$rec = News::where("is_rec_right", 1)->take(3)->get()->toArray();

		return view('user.information.news', ['data' => $model, "recNews" => $rec])->withIsInform(true)->withIsNews(true);
	}

	public function detail()
	{
		$nid = Input::get("nid");
		$model = News::where("id", $nid);
		if($model->count()){
			$data = $model->get()[0]->toArray();
		}else{
			return App::abort(404);
		}

		$rec = News::where("is_rec_right", 1)->take(3)->get()->toArray();
		return view('user.information.detail', ['data' => $data, "recNews" => $rec])->withIsInform(true);
	}

	public function getNewsList()
	{
	}


	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//
	}

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}
}
